package com.test;

import com.alibaba.fastjson.JSONObject;
import com.weixin.sendmsg.util.HttpUtil;
import com.weixin.sendmsg.util.JiNianRi;
import org.junit.Test;

import java.io.IOException;

/**
 * 2022/8/25  23:50
 * 星期四
 * 人生不过三万天!
 *
 * @author 小亮
 */
public class CaiHongPi {
    private static String URL = "https://api.shadiao.pro/chp";
    @Test
    public void test01() {
        String shengRi = String.valueOf(JiNianRi.getShengRi());
        String replace = shengRi.replace("-", "距离"); //获取指定字符串替换
        String substring = shengRi.substring(1);
        System.out.println("substring = " + substring);
        System.out.println(replace);
        String str = "abcdefghijklmnopqrstuvwxyz";
        System.out.println(str.substring(5));
    }
    public static String getCaiHongPi() {

        //默认彩虹屁
        String str = "阳光落在屋里，爱你藏在心里";
        try {
            JSONObject jsonObject = JSONObject.parseObject(HttpUtil.getUrl(URL));
             str = jsonObject.getJSONObject("data").getString("text");
            System.out.println("jsonObject = " + jsonObject);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }

    @Test
    public  void test02(){
        try {
            JSONObject jsonObject = JSONObject.parseObject(HttpUtil.getUrl("https://saying.api.azwcl.com/saying/get"));
            System.out.println("jsonObject = " + jsonObject);

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void test03(){
        getCaiHongPi();
    }
}
